import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store'
Vue.use(VueRouter)

const routes = [
    {
        path: '/login',
        name: 'login',
        component: () => import("../views/modules/login/login.vue"),
        meta: { requiresAuth: true } // 标记需登录访问
    },
    {
        path: '',
        redirect: '/home/activity',
        meta: { requiresAuth: true } // 标记需登录访问
    },
    {
        path: '/home',
        name: 'home',
        component: () => import("../views/modules/home.vue"),
        meta: { requiresAuth: true }, // 标记需登录访问
        children: [
            {
                path: 'unAuthorized',
                name: 'unAuthorized',
                name: 'activity',
                component: () => import("../views/modules/error/unAuthorized.vue")
            },
            {
                path: 'activity',
                name: 'activity',
                component: () => import("../views/modules/activity/activity.vue")
            },
            {
                path: 'activityRecord',
                name: 'activityRecord',
                component: () => import("../views/modules/activityRecord/activityrecord.vue")
            },
            {
                path: 'category',
                name: 'category',
                component: () => import("../views/modules/category/category.vue")
            },
            {
                path: 'fellow',
                name: 'fellow',
                component: () => import("../views/modules/fellow/fellow.vue")
            },
            {
                path: 'need',
                name: 'need',
                component: () => import("../views/modules/need/need.vue")
            },
            {
                path: 'recipient',
                name: 'recipient',
                component: () => import("../views/modules/recipient/recipient.vue")
            },
            {
                path: 'recipientRecord',
                name: 'recipientRecord',
                component: () => import("../views/modules/recipientRecord/recipientRecord.vue")
            },
            {
                path: 'information',
                name: 'information',
                component: () => import("../views/modules/activity/information.vue")
            },
            {
                path: 'aichat',
                name: 'aichat',
                component: () => import("../views/modules/ai/aiChat.vue")
            }
        ]
    },
]
// 防止重复导航错误 
const originalPush = VueRouter.prototype.push  
VueRouter.prototype.push  = function push(location) {
  return originalPush.call(this,  location).catch(err => {console.log(err)})
}
const router = new VueRouter({
    routes
})

export default router
